#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stdlib.h>
using namespace std;


string convertInt(int number)
{
   ostringstream ss;//create a stringstream
   ss << number;//add number to the stream
   return ss.str();//return a string with the contents of the stream
}

int main(int argc, char *argv[])
{
    if (argc < 2)
    {
      cout << "provide K (number of arrows) as an argument please." <<endl;
      return -1;
    }

    int K=atoi(argv[1]);


    string havij;

    havij=havij+convertInt(K)+"\n\n";
	
    for (int i=0;i<K;i++)
        havij=havij+"2 ";

    havij=havij+"\n\n";

    for (int i=0; i<K-1;i++)
    {
        for(int j=0;j<4;j++)
        {
            string tstr="";
            for(int k=0;k<i;k++)
            {
                tstr=tstr+"- ";
            }
            char tmp[10];
            snprintf(tmp,5,"%d %d ",j/2,j%2);
            tstr=tstr+tmp;
            for(int k=i;k<K-2;k++)
            {
                tstr=tstr+"- ";
            }
            char tstr2[tstr.length()+1];
            for(int k=0;k<tstr.length(); k++)
            {
                if (tstr[k] != '0' && tstr[k] != '1')
                    tstr2[k]= tstr[k];
                else
                {
                    tstr2[k]=tstr[k]=='0'?'1':'0';
                }
            }
            tstr2[tstr.length()]=0;
            tstr=tstr+"=> "+tstr2;
            havij=havij+tstr+"\n";
        }
    }
    havij=havij+"\nGOAL ";
    for (int i=0;i<K;i++)
        havij=havij+ "0 ";
    havij=havij+"\n";
    cout << havij;
}

/*
 * Generates K arrow PSVN files when state variables are state-of-an-arrow
 * originally written by Meysam Bastani
 * Edited by Shahab Jabbari
*/
